#!/usr/bin/python
#
"""Main page for mm2notes."""

__author__ = 'scottkirkwood@google.com (Scott Kirkwood)'

import datetime
import logging
import mm2notes
import os
import re
import schema
import time
import util

from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

import wsgiref.handlers

class Meeting(webapp.RequestHandler):
    """Handling of the meeting page."""

    @util.ForceLogin()
    def get(self, key):  # pylint: disable-msg=C6409
        """Standard GET request."""
        user = users.get_current_user()

        meeting = schema.Meeting.get(key)
        q = schema.Minutes.gql('WHERE meeting=:1 ORDER BY person', meeting)
        lines = []
        for line in q:
            lines.append(dict(person=line.person,
                    text=line.text))
        template_values = {
            'user': user,
            'key': key,
            'topic': meeting.topic,
            'attendees': meeting.attendees,
            'date': meeting.timestamp,
            'lines': lines,
        }
        path = os.path.join(os.path.dirname(__file__), 'meeting.html')
        body = template.render(path, template_values)
        self.response.out.write(body)

